import { Navigate, RouteObject } from 'react-router-dom';
import { EditView, GridView } from './components/view';
import { IndexView, Login, Page404 } from './pages';

const children: RouteObject[] = [
  {
    path: 'bookgridview',
    element: <GridView />,
  },
  {
    path: 'bookgridview/:bookgridview',
    element: <GridView />,
  },
  {
    path: 'bookeditview',
    element: <EditView />,
  },
  {
    path: 'bookeditview/:bookeditview',
    element: <EditView />,
  },
];

const routes: RouteObject[] = [
  {
    path: 'index',
    element: <IndexView />,
    children,
  },
  {
    path: 'index/:index',
    element: <IndexView />,
    children,
  },
  {
    path: 'login',
    element: <Login />,
  },
  {
    path: '404',
    element: <Page404 />,
  },
  {
    path: '/',
    element: <Navigate to='index' replace />,
  },
  {
    path: '*',
    element: <Navigate to='404' replace />,
  },
];

export default routes;
